package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
	"github.com/zeromicro/go-zero/core/logx"
)

type AppConfig struct {
	MysqlConfig
	ALiPayConfig
	QiNiuYunConfig
}
type MysqlConfig struct {
	Host     string
	Port     int64
	User     string
	Password string
	Database string
}
type ALiPayConfig struct {
	NotifyURL  string
	ReturnURL  string
	AppId      string
	PrivateKey string
}
type QiNiuYunConfig struct {
	AccessKey string
	SecretKey string
	Url       string
	Bucket    string
}

var AppConf AppConfig

func ConfigInit() {
	viper.SetConfigFile("../house_srv/appconfig/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		logx.Info("配置读取信息失败", err)
		return
	}
	logx.Info("配置读取信息成功")
	err = viper.Unmarshal(&AppConf)
	if err != nil {
		logx.Info("配置解析信息失败", err)
		return
	}
	logx.Info("配置解析信息成功")
	fmt.Println(AppConf)
}
